$(function(){
	
	$(".nav-font-tab").click(function(){
		$rt_asideW=$(".ul-tab").width()+20+"px";
		if($(".layer").css("opacity")==0){
			$(this).animate({"right":$rt_asideW},500);
			setTimeout(function(){
				$(".nav-font-tab hr:nth-child(2)").css("opacity","0").css({"left":"-40%"});
				$(".nav-font-tab hr:nth-child(3)").css("opacity","0").css({"right":"-40%"});
				$(".nav-font-tab hr:first-child").css({"transform":"rotate(46deg)","top":"-3px"});
				$(".nav-font-tab hr:last-child").css({"transform":"rotate(-45deg)","left":"-3px"});
				$(".ul-tab>li:first-child a").attr("class","rt-aside-active-link");
			},800)
			$(".layer").css({"opacity":"1","visibility":"visible"});
			$(".rt-aside").animate({"right":"0"},300);
		}
		else{
			layer_hidden();
		}
		
	})
	
	$(".layer-min").click(function(){
		layer_hidden();
	})
	
	function layer_hidden(){
		$(".rt-aside").animate({"right":"-24%"},300);
		setTimeout(function(){$(".nav-font-tab").animate({"right":"40px"},500)},300);
		setTimeout(function(){
			$(".nav-font-tab hr:nth-child(2)").css("opacity","1").css({"left":"0"});
			$(".nav-font-tab hr:nth-child(3)").css("opacity","1").css({"right":"0"});
			$(".nav-font-tab hr:first-child").css({"transform":"rotate(0)","top":"0"});
			$(".nav-font-tab hr:last-child").css({"transform":"rotate(0)","left":"0"});
		},800);
		setTimeout(function(){
			$(".layer").css({"opacity":"0","visibility":"hidden"});
			$(".ul-tab>li:first-child a").attr("class","");
		},600)
	}
	
	$(".ul-tab>li>a").mouseenter(function(){
		$(".ul-tab>li:first-child a").attr("class","");
		$index_li=$(this).parent().index();
		let $imove_all=$(".ul-tab").width()+26+"px";
		let $imove_all_height=$(".detail-box .move-all:nth-child(1)").height();
		let $change_all=parseInt($imove_all)-20+"px";
		$(".move-all").css("right",$imove_all);
		$(".detail-box .move-all").css({"right":$imove_all,"visibility":"hidden","opacity":"0"});
		if($index_li==1){
			$(".detail-box .move-all:first-child").css({"right":$change_all,"visibility":"visible","opacity":"1"})
		}
		if($index_li==4){
			let $off_height=(parseInt($(this).parent().offset().top)-parseInt($imove_all_height)/2)+20+"px";
			$(".detail-box .move-all:nth-child(2)").css({"right":$change_all,"visibility":"visible","opacity":"1","top":$off_height})
		}
		if($index_li==5){
			let $off_height=(parseInt($(this).parent().offset().top)-parseInt($imove_all_height)/2)+20+"px";
			$(".detail-box .move-all:nth-child(3)").css({"right":$change_all,"visibility":"visible","opacity":"1","top":$off_height})
		}
	})
	
	var $win_height=window.innerHeight;
	var $win_width=window.innerWidth;
	$("body").css("height",$win_height);
	$(".carousel-inner img").css("height",$win_height);
	setInterval(function(){
		window.onresize=function(){
			$win_height=window.innerHeight;
			$("body").css("height",$win_height);
			$(".carousel-inner img").css("height",$win_height);
		}
	},1)
	
	
	//轮播
	
	var indexxx=0;
	function xx(){
		let x_w=(-parseInt($(".show-slide-box").width())*indexxx)+"px";
		$(".swiper-wrapper").css("transform","translateX("+x_w+")")
		$(".swiper-pagination>li").removeClass("active-pagination")
		$($(".swiper-pagination>li")[indexxx]).addClass("active-pagination");
		$(".swiper-slide").removeClass("show-slide-box");
		$($(".swiper-slide")[indexxx]).addClass("show-slide-box");
	}
	
		
		var timer2 =setInterval(function(){
		indexxx++;
		indexxx=indexxx>2?indexxx=0:indexxx;
		xx();
		if(indexxx==0){
			animate_1()
		}
		if(indexxx==1){
			animate_2()
		}
		if(indexxx==2){
			animate_3()
		}
	},5000)
		
		$(".swiper-pagination>li").click(function(){
			clearInterval(timer2)
			timer=null;
			indexxx=$(this).index();
//			indexxx=indexxx>2?indexxx=0:indexxx;
			
			xx();
			$(".jianjian li span").removeClass("active-li-sp");
			$($(".jianjian li span")[indexxx]).addClass("active-li-sp");
			if(indexxx==0){
				animate_1()
			}
			if(indexxx==1){
				animate_2()
			}
			if(indexxx==2){
				animate_3()
			}
		})
	
	
	$(".trans_el").each(function(){
			$(this)[0].addEventListener("animationend",function(){
			$(this).attr("class","")
		})
	})	
	
	
	function animate_1(){
		$(".font-max h2").addClass("animated bounceIn trans_el")
		$(".font-max-next h3").addClass("animated bounceInLeft trans_el")
		$(".font-max-next h4").addClass("animated bounceInRight trans_el")
		$(".font-max-next h2").addClass("animated fadeInDown trans_el")
		$(".lt-row2 h3").addClass("animated fadeInDown trans_el")
		$(".lt-row2 li").addClass("animated lightSpeedIn trans_el")
		$(".con-p p").addClass("animated bounceInRight trans_el")
	}
	
	function animate_2(){
		$(".slide-con2-row1 h3").addClass("animated bounceInLeft trans_el")
		$(".slide-con2-row1 h4").addClass("animated bounceInRight trans_el")
		$(".slide-con2-row2 p").addClass("animated fadeInDown trans_el")
		$(".slide-con2-row2 ul").addClass("animated fadeInDown trans_el")
		$(".slide-con2-row3 h3").addClass("animated flipInX trans_el")
		$(".slide-con2-row3 p").addClass("animated flipInY trans_el")
	}
	
	function animate_3(){
		$(".lt-line-box").addClass("animated bounceIn")
		$(".rt-con-box h3").addClass("animated rotateInUpLeft")
		$(".rt-con-box p").addClass("animated rotateInUpRight")
		$(".rt-con-box h2").addClass("animated zoomInUp")
		$(".rt-con-box h4").addClass("animated fadeInDown")
	}
	
	function animate_4(){
		$(".about-content .lt-con h4").addClass("animated bounceInLeft trans_el")
		$(".about-content .lt-con h3").addClass("animated bounceInRight trans_el")
		$(".about-content .lt-con>p").addClass("animated flipInX trans_el")
		$(".about-content .lt-con .link-more p").addClass("animated flipInY trans_el")
	}
		
	function animate_5(){
		$(".sec3-max h3").addClass("animated bounceIn trans_el");
		$(".sec3-max>ul").addClass("animated pulse trans_el");
	}
		
	$(".swiper-pagination li").mouseenter(function(){
		let $index=$(this).index();
		$(".jianjian li span").removeClass("active-li-sp");
		$($(".jianjian li span")[$index]).addClass("active-li-sp");
		if($index==1){
			$(".time-font").css({"opacity":"0","bottom":"8%"});
			$flag=0;
		}
	})
	$(".swiper-pagination li").mouseout(function(){
		$(".jianjian li span").removeClass("active-li-sp");
	})

	let $flag=1,
		timer1=null;
	function startfont_play(){
		timer1=setInterval(function(){
			if($flag){
				$(".time-font").css({"opacity":"0","bottom":"8%"});
				$flag=0;
			}
			else{
				$(".time-font").css({"opacity":"1","bottom":"10%"});
				$flag=1;
			}
		},2000)
	}
	startfont_play()
	
	
	
	
	//media
	
	//全兼容的 事件绑定  and  阻止默认事件
     var EventUtil = {
  //Notice: type is not include 'on', for example: click mouseover mouseout and so on
          addHandler: function(element, type, handler){
              if (element.addEventListener){
                  element.addEventListener(type, handler, false);
              } else if(element.attachEvent){
                  element.attachEvent('on'+type, handler);
              } else {
                 element['on'+type] = handler;
             }
        },
 
         preventDefault: function(event){
             if(event.preventDefault){
                 event.preventDefault();
             }else{
                 event.returnValue = false;
             }
         }
     };
     var mediaQuery = {
         init:function(){
             var _this = this;
             _this.outputSize();
            EventUtil.addHandler(window,"resize",function(){
                 _this.outputSize();
             });
        },
         outputSize:function(){
             var result1 = window.matchMedia('(min-width:1200px)');
             var result2 = window.matchMedia('(min-width:992px)');
             var result3 = window.matchMedia('(min-width:768px)');
            if(result1.matches) {
//               console.log(">=1200 大型设备 大台式电脑");
                 
                 
                 
             }else if(result2.matches){
//               console.log("992=< <=1200 中型设备 台式电脑");
                 
                 
                 
             }else if(result3.matches){
//               console.log("768<= <=992 小型设备 平板电脑");
                 
            }else{
//               console.log("<=768 超小设备 手机");
                 $(".font-max h2").appendTo(".font-max-next h2").
                 css({"float":"left","margin-right":"40px","font-size":"54px","color":"#ffc012","margin-top":"-6px"
                 ,"border":"none","padding":"0","margin":"0"});
             }
         }
    };
     window.onload = function(){
         mediaQuery.init();
     };
     
     
     
     
     
    //fullage.js
    
    $('#fullPage').fullpage({
				sectionsColor: ['#1bbc9b', '#4BBFC3', '#7BAABE', '#f90'],
				anchors: ['page1', 'page2', 'page3', 'page4'],
				menu: '#menu',
				afterLoad:function(anchorLink,index){
					//切换导航
					
					//在第一屏
					if(index==1){
						var nav_taba=$($(".nav-tab-li>li>a")[index-1]);
						indexxx=0;
						animate_1();
						changenav_tab(index-1);
					}
					//第二屏
					if(index==2){
						 $("#dataNums0").numberAnimate({num:22,speed:3000});
					     $("#dataNums1").numberAnimate({num:5700,speed:3000});
					     $("#dataNums2").numberAnimate({num:4,speed:3000});
					     $("#dataNums3").numberAnimate({num:15,speed:3000});
					     animate_4();
						changenav_tab(index-1);				     
					}
					if(index==3){
						changenav_tab(index-1);	
						animate_5();
					}
					if(index==4){
						changenav_tab(index-1);		
					}
               },
               onLeave:function(anchorLink,index){
               	
               }
			});
    
    var _hmt = _hmt || [];
		(function() {
		  var hm = document.createElement("script");
		  hm.src = "https://hm.baidu.com/hm.js?319df46884458c3fbee36b0cc6e390e8";
		  var s = document.getElementsByTagName("script")[0]; 
		  s.parentNode.insertBefore(hm, s);
		})();


	

	//nav tab
	$(".nav-tab-li>li>a").click(function(){
		
		var index_a=$(".nav-tab-li>li>a").index($(this));
		changenav_tab(index_a);
	})

	//改变导航样式
	function changenav_tab(index){
		 var nav_taba=$($(".nav-tab-li>li>a")[index]);
		 nav_taba.parent().siblings().removeClass("li_weil")
		 nav_taba.parent().addClass("li_weil");
		 $(".nav-tab-li>li").removeClass("active-nav-item")
		 nav_taba.addClass("active-nav-item");
	}
	
	
	//sec2右侧轮播
	function slider(){
			let img_width=$(".rt-slide-max").width();
			let fir=$(".rt-slide-mid img:first-child");
			fir.css({
				"margin-left":-img_width
			});
			setTimeout(function(){
				fir.appendTo(".rt-slide-mid").css("margin-left","0")
			},1000)
		}
		setInterval(function(){
			slider();
		},1000)
	
	
	$(".rt-aside").mouseover(function(){
		$.fn.fullpage.setAllowScrolling(false);
		
	})
	
	$(".rt-aside").mouseout(function(){
		$.fn.fullpage.setAllowScrolling(true);
	})
     
     
     
     //sec3轮播
     
     
     function sec3_slide(){
			let fir=$(".sec3_slide>.ul-show>li:first-child");
			let li_width=-$(".sec3_slide>.ul-show>li").width()+"px"
			fir.css({
				"margin-left":li_width
			});
			setTimeout(function(){
				fir.appendTo(".sec3_slide>.ul-show").css("margin-left","0")
			},1000)
		}
     
    function sec3_next(){
    	let li_width=-$(".sec3_slide>.ul-show>li").width()+"px";
    	let las=$(".sec3_slide>.ul-show>li:last-child");
    	console.log(las)
		las.insertBefore($(".sec3_slide>.ul-show>li:first-child")).css("margin-left",li_width);
		las.animate({
			"margin-left":"0px"
		},1)
    	}
    
	   $(".sec3-prev").click(function(){
		   if(timer_sec3){
	   			clearInterval(timer_sec3)
		   		timer_sec3=null
	   		}
	   		sec3_slide();
	   })
	   
	   $(".sec3-next").click(function(){
	   		if(timer_sec3){
	   			clearInterval(timer_sec3)
		   		timer_sec3=null
	   		}
	   		sec3_next()
	   })
	   
		timer_sec3=setInterval(function(){
			sec3_slide();
		},3000)
     
     //点击切换轮播
     $(".sec3-max>ul>li").click(function(){
     	let li_ind= $(".sec3-max>ul>li").index($(this));
     	let mid_span=$(".sec3-max>ul>li a span");
     	mid_span.removeClass("active");
     	$(mid_span[li_ind]).addClass("active");
 		$(".sec3_slide>ul").removeClass("ul-show")
 		$($(".sec3_slide>ul")[li_ind]).addClass("ul-show");
     })
})
